-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lowering: Disallow splatting in non-final default value #50563
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Keno
force-pushed
the
kf/disallownonfinaldefaultsplat
branch
from
July 15, 2023 17:36
4744bb1
to
e21aece
Compare
Pop quiz: Do you know what the following will do? ``` julia> function g1(a=(1,2)..., b...=3) b end julia> g1() julia> function g2(a=(1,2)..., b=3, c=4) (b, c) end julia> g2() julia> function g3(a=(1,2)..., b=3, c...=4) (b, c) end julia> g3() julia> g3(1) ``` I don't either and I don't think it's particularly well defined. Splatting a default argument makes sense on the last argument, which can be a vararg, and it is desirable to be able to specify the default for the whole varargs tuple at once (although arguably that should just be the non-`...` behavior, but that'd be too breaking a change). Ref #50518. However, for other arguments, there isn't really a sensible semantic meaning. This PR disallows this in lowering. This is technically a minor change, but I doubt anybody is using this. Splatting in default values wasn't really ever supposed to work anyway, it just happened to fall out of our lowering.
Keno
force-pushed
the
kf/disallownonfinaldefaultsplat
branch
from
July 15, 2023 17:54
e21aece
to
b5bb8f3
Compare
Is the variant from the issue still allowed? function f(xs...=["a", "b", "c"]...; debug=false)
return xs[1]
end Maybe worth a test? |
Yes, it's allowed and was added as a test in #50559. |
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Keno
force-pushed
the
kf/disallownonfinaldefaultsplat
branch
from
July 17, 2023 15:24
75c18f9
to
69d7385
Compare
Let's see if Nanosoldier finds any packages: @nanosoldier |
The package evaluation job you requested has completed - possible new issues were detected. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pop quiz: Do you know what the following will do?
I don't either and I don't think it's particularly well defined. Splatting a default argument makes sense on the last argument, which can be a vararg, and it is desirable to be able to specify the default for the whole varargs tuple at once (although arguably that should just be the non-
...
behavior, but that'd be too breaking a change). Ref #50518. However, for other arguments, there isn't really a sensible semantic meaning. This PR disallows this in lowering. This is technically a minor change, but I doubt anybody is using this. Splatting in default values wasn't really ever supposed to work anyway, it just happened to fall out of our lowering.